import { connect } from 'dva'
import RiskEvaluate from '../../../components/RiskEvaluate'
import styles from './risk.scss'
import { Button, Checkbox } from 'antd-mobile'

const CheckboxItem = Checkbox.CheckboxItem;
const RiskResult = ({
  switchClauseResult,
  dispatch
}) => {
  let toNextPage = () => {
    dispatch({
      type: "modules/getModules",
      payload: {
        pathname: "",
        businessId: "1231241214",
        process: "riskEvaluate",
        title: "风险评测"
      }
    })
  }
  let evaluateAgain = () => {
    dispatch({
      type: "modules/getModules",
      payload: {
        pathname: "",
        businessId: "1231241226-r",
        process: "riskEvaluate",
        title: "风险评测"
      }
    })
  }
  //勾选协议
  let selectClause = (e) => {
    dispatch({
      type: 'riskEvaluate/changeClause',
      payload: {
        switchClauseResult: e.target.checked
      }
    })
  }
  return (
    <div className={styles.riskContain}>
      <div className={styles.document}>
        <RiskEvaluate></RiskEvaluate>
        <div className={styles.checkClause}>
          <CheckboxItem onChange={selectClause} defaultChecked={switchClauseResult}>我已阅读并知悉上述内容</CheckboxItem>
        </div>
      </div>
      <div className={styles.footer}>
        <div className={styles.myButton}>
          <Button onClick={evaluateAgain}>重新评测</Button>
        </div>
        <div className={styles.myButton}>
          <Button type="primary" disabled={!switchClauseResult} onClick={toNextPage}>同意并确认</Button>
        </div>
      </div>
    </div>
  )
}


export default connect((state) => state.riskEvaluate )(RiskResult)

